package com.hippo.core.controller;

import com.alibaba.fastjson.JSONObject;
import com.hippo.core.config.annotation.RequiresPermissions;
import com.hippo.core.service.CaseGenerateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @author: hippo
 */
@RestController
public class CaseGenerateController {

    @Autowired
    private CaseGenerateService caseGenerateService;

    @RequiresPermissions("caseGenerate:generateCase")
    @PostMapping("/generateCase")
    public JSONObject generateCase(@RequestBody JSONObject obj) throws Exception {
        return caseGenerateService.generateCase(obj);
    }

    @RequiresPermissions("caseGenerate:exportCaseExcel")
    @PostMapping(value = "/exportCaseExcel")
    public void exportExcel(@RequestBody JSONObject data, HttpServletResponse response) throws Exception {
        caseGenerateService.exportCaseExcel(data, response);
    }
}
